<?php

namespace Home\Controller;

/**
 * Description of ReportController.class控制器实例
 *
 * @author songanwei
 * @date 2016-1-18
 */
class ReportController extends ParentController {

    protected function _initialize() {
        parent::_initialize();
        $this->validateUtil = new \Org\Util\Validate();
        $hotel = I('request.hotel');
        //检查客栈是否已过期
        $hotelLogic = A('Common/Hotel', 'Logic');
        $result = $hotelLogic->checkHotelActive($hotel);
        if ($result == false) {
            returnJson(403, 408);
        }
        //检查操作权限
        $adminAuthorityLogic = A('Common/AdminAuthority', 'Logic');
        $adminAuthorityLogic->check($hotel);
    }

    /**
     * @description 查询统计概览数据
     * @modify songanwei 2016-01-19
     * @modify zhangzhen 2017-06-06 钟点房
     */
    public function getOverview() {
        $params = I('post.');
        $validateRule = array(
            'hotel' => 'notnull,notempty,id',
            'start' => 'notnull,notempty,isDate',
            'end' => 'notnull,notempty,isDate',
        );
        //检查参数
        $this->ajaxValidateReturn($this->validateUtil, $params, $validateRule);
        $hotelId = $params['hotel'];
        $startDate = $params['start'];
        $endDate = $params['end'];
        //检查权限
        //查询数据
        $reportLogic = A('Common/Report', 'Logic');
        $summary = $reportLogic->getSummary($hotelId, $startDate, $endDate);

        // 记账数据
        $accountView = $reportLogic->getHotelAccountView($hotelId, null, $startDate, $endDate);

        //获取当前日期
        $currentDate = date('Y-m-d');
        $yesterdayDate = date('Y-m-d', strtotime('-1 days'));

        //查询今天数据
        $todaySummary = $reportLogic->getTodaySummary($hotelId, $currentDate);
        $todayRoomReport = $reportLogic->getTodayRoomReport($hotelId, $currentDate);
        //查询昨天数据
        $yesterdaySummary = $reportLogic->getTodaySummary($hotelId, $yesterdayDate);
        $yesterdayRoomReport = $reportLogic->getTodayRoomReport($hotelId, $yesterdayDate);

        //获取订单总收入
        $data['income'] = $summary['receipt'] + $summary['deposit'];
        //获取总收款
        //$data['incomeReceipt'] = $summary['receipt'];
        //获取总共收取押金
        //$data['incomeDeposit'] = $summary['deposit'];
        //获取订单总支出
        $data['outcome'] = $summary['refund'] + $summary['refundDeposit'];
        //outcomeRefund退款
        //$data['outcomeRefund'] = $summary['refund'];
        //outcomeDeposit退押金
        //$data['outcomeDeposit'] = $summary['refundDeposit'];
        //计算订单总结余
        $data['surplus'] = number_format($data['income'] - $data['outcome'], 2, '.', '');

        // 记账总收入
        $data['noteincome'] = $accountView['income'];
        // 记账总支出
        $data['noteoutcome'] = $accountView['outcome'];
        //记账总结余
        $data['notesurplus'] = number_format($accountView['income'] - $accountView['outcome'], 2, '.', '');

        // 财务收支总结余
        $data['financesurplus'] = number_format($data['surplus'] + $data['notesurplus'], 2, '.', '');

        $data['today'] = array(
            'income' => $todaySummary['receipt'],
            'roomCount' => $todayRoomReport['roomTotal'],
            'occupancyRate' => round($todayRoomReport['occupancyRate'] * 100, 2) . "%",
            'price' => $todayRoomReport['price'],
            'notSold' => $todayRoomReport['notSold'],
            'notCheckIn' => $todayRoomReport['notCheckIn'],
        );
        $data['yesterday'] = array(
            'income' => $yesterdaySummary['receipt'],
            'roomCount' => $yesterdayRoomReport['roomTotal'],
            'occupancyRate' => round($yesterdayRoomReport['occupancyRate'] * 100, 2) . "%",
            'price' => $yesterdayRoomReport['price'],
            'notSold' => $yesterdayRoomReport['notSold'],
            'notCheckIn' => $yesterdayRoomReport['notCheckIn']
        );
        $hourRoomInitModel = D('HourRoomInit');
        $hourRoomInitInfo = $hourRoomInitModel->getInfo($hotelId);
        if ($hourRoomInitInfo) {
            //查询今天数据
            $todayHourSummary = $reportLogic->getTodayHourSummary($hotelId, $currentDate);
            $todayHourRoomReport = $reportLogic->getTodayHourRoomReport($hotelId, $currentDate);
            $data['todayHour'] = array(
                'income' => $todayHourSummary['receipt'],
                'roomCount' => $todayHourRoomReport['roomTotal'],
                'occupancyRate' => round($todayHourRoomReport['occupancyRate'] * 100, 2) . "%",
                'price' => $todayHourRoomReport['price'],
                'notSold' => $todayHourRoomReport['roomTotal'] - $todayHourRoomReport['rest'],
                'notCheckIn' => $todayHourRoomReport['notCheckIn'],
            );

            $yesterdayHourSummary = $reportLogic->getTodayHourSummary($hotelId, $yesterdayDate);
            $yesterdayHourRoomReport = $reportLogic->getTodayHourRoomReport($hotelId, $yesterdayDate);

            $data['yesterdayHour'] = array(
                'income' => $yesterdayHourSummary['receipt'],
                'roomCount' => $yesterdayHourRoomReport['roomTotal'],
                'occupancyRate' => round($yesterdayHourRoomReport['occupancyRate'] * 100, 2) . "%",
                'price' => $yesterdayHourRoomReport['price'],
                'notSold' => $yesterdayHourRoomReport['roomTotal']-$yesterdayHourRoomReport['rest'],
                'notCheckIn' => $yesterdayHourRoomReport['notCheckIn'],
            );
        }
        $roomTypetModel = D('RoomType');
        $monthRoomInitInfo = $roomTypetModel
            ->where([
                'hotelentity_id' => $hotelId,
                'longprice' => ['NEQ', 0.00],
            ]);
        if ($monthRoomInitInfo) {
            $nowMonth = date('Y-m-1');
            $lastMonth = date('Y-m-d',strtotime('-1 months', strtotime($nowMonth)));
            //查询今天数据
            $todayMonthSummary = $reportLogic->getMonthSummary($hotelId, $nowMonth);
            $todayMonthRoomReport = $reportLogic->getMonthRoomReport($hotelId, $nowMonth);
            $data['todayMonth'] = array(
                'income' => $todayMonthSummary['receipt'],
                'roomCount' => $todayMonthRoomReport['roomTotal'],
                'occupancyRate' => round($todayMonthRoomReport['occupancyRate'] * 100, 2) . "%",
                'price' => $todayMonthRoomReport['price'],
                'notSold' => $todayMonthRoomReport['roomTotal'] - $todayMonthRoomReport['rest'],
                'notCheckIn' => $todayMonthRoomReport['notCheckIn'],
            );

            $yesterdayMonthSummary = $reportLogic->getMonthSummary($hotelId, $lastMonth);
            $yesterdayMonthRoomReport = $reportLogic->getMonthRoomReport($hotelId, $lastMonth);

            $data['yesterdayMonth'] = array(
                'income' => $yesterdayMonthSummary['receipt'],
                'roomCount' => $yesterdayMonthRoomReport['roomTotal'],
                'occupancyRate' => round($yesterdayMonthRoomReport['occupancyRate'] * 100, 2) . "%",
                'price' => $yesterdayMonthRoomReport['price'],
                'notSold' => $yesterdayMonthRoomReport['roomTotal']-$yesterdayMonthRoomReport['rest'],
                'notCheckIn' => $yesterdayMonthRoomReport['notCheckIn'],
            );
        }

        returnJson(200, 200, $data);
    }

    /**
     * @description 导出统计概览昨日对比
     * @modify songanwei 2016-01-18
     * @modify zhangzhen 2017-06-06 钟点房
     */
    public function exportList() {
        $param = I('get.');
        $hotelId = $param['hotel'];
        //检查权限
        Vendor('phpExcel.PHPExcel');
        $phpExcel = new \PHPExcel();
        //Excel5格式
        $objWriter = new \PHPExcel_Writer_Excel5($phpExcel);
        //查询客栈数据
        $hotelEntityModel = D('HotelEntity');
        $hotelEntity = $hotelEntityModel->getInfo($hotelId);
        //输出文件名
        $outputFileName = $hotelEntity['name'] . date("Y.m.d");
        switch (LANG_SET) {
            case 'en_us':
                $outputFileName .= "Comparison of revenue and expenditure";
                //设置导出Excel标题
                $phpExcel->setActiveSheetIndex(0);
                $phpExcel->getActiveSheet()->setCellValue('A1', ''); //可以指定位置
                $phpExcel->getActiveSheet()->setCellValue('B1', 'Income');
                $phpExcel->getActiveSheet()->setCellValue('C1', 'Room quantity');
                $phpExcel->getActiveSheet()->setCellValue('D1', 'Occupancy rate');
                $phpExcel->getActiveSheet()->setCellValue('E1', 'Average price');
                $phpExcel->getActiveSheet()->setCellValue('F1', 'Unsold');
                $phpExcel->getActiveSheet()->setCellValue('G1', 'No check in');
                break;
             case 'zh_tw':
                $outputFileName .= "收支對比";
                //设置导出Excel标题
                $phpExcel->setActiveSheetIndex(0);
                $phpExcel->getActiveSheet()->setCellValue('A1', ''); //可以指定位置
                $phpExcel->getActiveSheet()->setCellValue('B1', '收入');
                $phpExcel->getActiveSheet()->setCellValue('C1', '房間數');
                $phpExcel->getActiveSheet()->setCellValue('D1', '入住率');
                $phpExcel->getActiveSheet()->setCellValue('E1', '平均價格');
                $phpExcel->getActiveSheet()->setCellValue('F1', '未售出');
                $phpExcel->getActiveSheet()->setCellValue('G1', '未入住');
                break;
            default:
                $outputFileName .= "收支对比";
                //设置导出Excel标题
                $phpExcel->setActiveSheetIndex(0);
                $phpExcel->getActiveSheet()->setCellValue('A1', ''); //可以指定位置
                $phpExcel->getActiveSheet()->setCellValue('B1', '收入');
                $phpExcel->getActiveSheet()->setCellValue('C1', '房间数');
                $phpExcel->getActiveSheet()->setCellValue('D1', '入住率');
                $phpExcel->getActiveSheet()->setCellValue('E1', '平均价格');
                $phpExcel->getActiveSheet()->setCellValue('F1', '未售出');
                $phpExcel->getActiveSheet()->setCellValue('G1', '未入住');
                break;
        }
        
        $reportLogic = A('Common/Report', 'Logic');
        //获取当前日期
        $currentDate = date('Y-m-d');
        $yesterdayDate = date('Y-m-d', strtotime('-1 days'));
        //查询今天数据
        $todaySummary = $reportLogic->getTodaySummary($hotelId, $currentDate);
        $todayRoomReport = $reportLogic->getTodayRoomReport($hotelId, $currentDate);
        //查询昨天数据
        $yesterdaySummary = $reportLogic->getTodaySummary($hotelId, $yesterdayDate);
        $yesterdayRoomReport = $reportLogic->getTodayRoomReport($hotelId, $yesterdayDate);

        $data[] = array(
            'date' => $yesterdayDate,
            'income' => $yesterdaySummary['receipt'],
            'roomCount' => $yesterdayRoomReport['roomTotal'],
            'occupancyRate' => round($yesterdayRoomReport['occupancyRate'] * 100, 2) . "%",
            'price' => $yesterdayRoomReport['price'],
            'notSold' => $yesterdayRoomReport['notSold'],
            'notCheckIn' => $yesterdayRoomReport['notCheckIn']
        );
        $data[] = array(
            'date' => $currentDate,
            'income' => $todaySummary['receipt'],
            'roomCount' => $todayRoomReport['roomTotal'],
            'occupancyRate' => round($todayRoomReport['occupancyRate'] * 100, 2) . "%",
            'price' => $todayRoomReport['price'],
            'notSold' => $todayRoomReport['notSold'],
            'notCheckIn' => $todayRoomReport['notCheckIn'],
        );

        //获取表单数据
        for ($i = 0; $i < count($data); $i++) {
            $phpExcel->getActiveSheet()->setCellValue('A' . ($i + 2), $data[$i]['date']);
            $phpExcel->getActiveSheet()->setCellValue('B' . ($i + 2), $data[$i]['income']);
            $phpExcel->getActiveSheet()->setCellValue('C' . ($i + 2), $data[$i]['roomCount']);
            $phpExcel->getActiveSheet()->setCellValue('D' . ($i + 2), $data[$i]['occupancyRate']);
            $phpExcel->getActiveSheet()->setCellValue('E' . ($i + 2), $data[$i]['price']);
            $phpExcel->getActiveSheet()->setCellValue('F' . ($i + 2), $data[$i]['notSold']);
            $phpExcel->getActiveSheet()->setCellValue('G' . ($i + 2), $data[$i]['notCheckIn']);
        }

        //输出excel文档
        phpExcelOutput($objWriter, $outputFileName);
    }

    /**
     * @description 导出统计概览昨日对比
     * @modify zhangzhen 2017-06-06 钟点房
     */
    public function exportHourList() {
        $param = I('get.');
        $hotelId = $param['hotel'];
        //检查权限
        Vendor('phpExcel.PHPExcel');
        $phpExcel = new \PHPExcel();
        //Excel5格式
        $objWriter = new \PHPExcel_Writer_Excel5($phpExcel);
        //查询客栈数据
        $hotelEntityModel = D('HotelEntity');
        $hotelEntity = $hotelEntityModel->getInfo($hotelId);

        $outputFileName = $hotelEntity['name'] . date("Y.m.d") . "收支对比";
        //输出文件名
        //设置导出Excel标题
        $phpExcel->setActiveSheetIndex(0);
        $phpExcel->getActiveSheet()->setCellValue('A1', ''); //可以指定位置
        $phpExcel->getActiveSheet()->setCellValue('B1', '收入');
        $phpExcel->getActiveSheet()->setCellValue('C1', '房间数');
        $phpExcel->getActiveSheet()->setCellValue('D1', '入住率');
        $phpExcel->getActiveSheet()->setCellValue('E1', '平均价格');
        $phpExcel->getActiveSheet()->setCellValue('F1', '未售出');
        $phpExcel->getActiveSheet()->setCellValue('G1', '未入住');
        $reportLogic = A('Common/Report', 'Logic');
        //获取当前日期
        $currentDate = date('Y-m-d');
        $yesterdayDate = date('Y-m-d', strtotime('-1 days'));
        //查询今天数据
        $todayHourSummary = $reportLogic->getTodayHourSummary($hotelId, $currentDate);
        $todayHourRoomReport = $reportLogic->getTodayHourRoomReport($hotelId, $currentDate);
        //查询昨天数据
        $yesterdayHourSummary = $reportLogic->getTodayHourSummary($hotelId, $yesterdayDate);
        $yesterdayHourRoomReport = $reportLogic->getTodayHourRoomReport($hotelId, $yesterdayDate);

        $data[] = array(
            'date' => $yesterdayDate,'income' => $yesterdayHourSummary['receipt'],
            'roomCount' => $yesterdayHourRoomReport['roomTotal'],
            'occupancyRate' => round($yesterdayHourRoomReport['occupancyRate'] * 100, 2) . "%",
            'price' => $yesterdayHourRoomReport['price'],
            'notSold' => $yesterdayHourRoomReport['notSold'],
            'notCheckIn' => $yesterdayHourRoomReport['notCheckIn'],
        );
        $data[] = array(
            'date' => $currentDate,
            'income' => $todayHourSummary['receipt'],
            'roomCount' => $todayHourRoomReport['roomTotal'],
            'occupancyRate' => round($todayHourRoomReport['occupancyRate'] * 100, 2) . "%",
            'price' => $todayHourRoomReport['price'],
            'notSold' => $todayHourRoomReport['notSold'],
            'notCheckIn' => $todayHourRoomReport['notCheckIn']
        );

        //获取表单数据
        for ($i = 0; $i < count($data); $i++) {
            $phpExcel->getActiveSheet()->setCellValue('A' . ($i + 2), $data[$i]['date']);
            $phpExcel->getActiveSheet()->setCellValue('B' . ($i + 2), $data[$i]['income']);
            $phpExcel->getActiveSheet()->setCellValue('C' . ($i + 2), $data[$i]['roomCount']);
            $phpExcel->getActiveSheet()->setCellValue('D' . ($i + 2), $data[$i]['occupancyRate']);
            $phpExcel->getActiveSheet()->setCellValue('E' . ($i + 2), $data[$i]['price']);
            $phpExcel->getActiveSheet()->setCellValue('F' . ($i + 2), $data[$i]['notSold']);
            $phpExcel->getActiveSheet()->setCellValue('G' . ($i + 2), $data[$i]['notCheckIn']);
        }

        //输出excel文档
        phpExcelOutput($objWriter, $outputFileName);
    }

    /**
     * @description 导出统计概览昨日对比
     * @modify zhangzhen 2017-08-14 长租房
     */
    public function exportLongList() {
        $param = I('get.');
        $hotelId = $param['hotel'];
        //检查权限
        Vendor('phpExcel.PHPExcel');
        $phpExcel = new \PHPExcel();
        //Excel5格式
        $objWriter = new \PHPExcel_Writer_Excel5($phpExcel);
        //查询客栈数据
        $hotelEntityModel = D('HotelEntity');
        $hotelEntity = $hotelEntityModel->getInfo($hotelId);
        //输出文件名
        $outputFileName = $hotelEntity['name'] . date("Y.m.d");
        switch (LANG_SET) {
            case 'en_us':
                $outputFileName .= "Comparison of revenue and expenditure";
                //设置导出Excel标题
                $phpExcel->setActiveSheetIndex(0);
                $phpExcel->getActiveSheet()->setCellValue('A1', ''); //可以指定位置
                $phpExcel->getActiveSheet()->setCellValue('B1', 'Income');
                $phpExcel->getActiveSheet()->setCellValue('C1', 'Room quantity');
                $phpExcel->getActiveSheet()->setCellValue('D1', 'Occupancy rate');
                $phpExcel->getActiveSheet()->setCellValue('E1', 'Average price');
                $phpExcel->getActiveSheet()->setCellValue('F1', 'Unsold');
                $phpExcel->getActiveSheet()->setCellValue('G1', 'No check in');
                break;
             case 'zh_tw':
                $outputFileName .= "收支對比";
                //设置导出Excel标题
                $phpExcel->setActiveSheetIndex(0);
                $phpExcel->getActiveSheet()->setCellValue('A1', ''); //可以指定位置
                $phpExcel->getActiveSheet()->setCellValue('B1', '收入');
                $phpExcel->getActiveSheet()->setCellValue('C1', '房間數');
                $phpExcel->getActiveSheet()->setCellValue('D1', '入住率');
                $phpExcel->getActiveSheet()->setCellValue('E1', '平均價格');
                $phpExcel->getActiveSheet()->setCellValue('F1', '未售出');
                $phpExcel->getActiveSheet()->setCellValue('G1', '未入住');
                break;
            default:
                $outputFileName .= "收支对比";
                //设置导出Excel标题
                $phpExcel->setActiveSheetIndex(0);
                $phpExcel->getActiveSheet()->setCellValue('A1', ''); //可以指定位置
                $phpExcel->getActiveSheet()->setCellValue('B1', '收入');
                $phpExcel->getActiveSheet()->setCellValue('C1', '房间数');
                $phpExcel->getActiveSheet()->setCellValue('D1', '入住率');
                $phpExcel->getActiveSheet()->setCellValue('E1', '平均价格');
                $phpExcel->getActiveSheet()->setCellValue('F1', '未售出');
                $phpExcel->getActiveSheet()->setCellValue('G1', '未入住');
                break;
        }
        
        $reportLogic = A('Common/Report', 'Logic');
        //获取当前日期
        $currentDate = date('Y-m-d');
        $yesterdayDate = date('Y-m-d', strtotime('-1 days'));
        //查询今天数据
        $todaySummary = $reportLogic->getTodayMonthSummary($hotelId, $currentDate);
        $todayRoomReport = $reportLogic->getTodayMonthRoomReport($hotelId, $currentDate);
        //查询昨天数据
        $yesterdaySummary = $reportLogic->getTodayMonthSummary($hotelId, $yesterdayDate);
        $yesterdayRoomReport = $reportLogic->getTodayMonthRoomReport($hotelId, $yesterdayDate);

        $data[] = array(
            'date' => $yesterdayDate,
            'income' => $yesterdaySummary['receipt'],
            'roomCount' => $yesterdayRoomReport['roomTotal'],
            'occupancyRate' => round($yesterdayRoomReport['occupancyRate'] * 100, 2) . "%",
            'price' => $yesterdayRoomReport['price'],
            'notSold' => $yesterdayRoomReport['notSold'],
            'notCheckIn' => $yesterdayRoomReport['notCheckIn']
        );
        $data[] = array(
            'date' => $currentDate,
            'income' => $todaySummary['receipt'],
            'roomCount' => $todayRoomReport['roomTotal'],
            'occupancyRate' => round($todayRoomReport['occupancyRate'] * 100, 2) . "%",
            'price' => $todayRoomReport['price'],
            'notSold' => $todayRoomReport['notSold'],
            'notCheckIn' => $todayRoomReport['notCheckIn'],
        );

        //获取表单数据
        for ($i = 0; $i < count($data); $i++) {
            $phpExcel->getActiveSheet()->setCellValue('A' . ($i + 2), $data[$i]['date']);
            $phpExcel->getActiveSheet()->setCellValue('B' . ($i + 2), $data[$i]['income']);
            $phpExcel->getActiveSheet()->setCellValue('C' . ($i + 2), $data[$i]['roomCount']);
            $phpExcel->getActiveSheet()->setCellValue('D' . ($i + 2), $data[$i]['occupancyRate']);
            $phpExcel->getActiveSheet()->setCellValue('E' . ($i + 2), $data[$i]['price']);
            $phpExcel->getActiveSheet()->setCellValue('F' . ($i + 2), $data[$i]['notSold']);
            $phpExcel->getActiveSheet()->setCellValue('G' . ($i + 2), $data[$i]['notCheckIn']);
        }

        //输出excel文档
        phpExcelOutput($objWriter, $outputFileName);
    }

    /**
     * 财务收支ajax接口
     * @modify AmosZhong 2016-01-18
     */
    public function getFinance() {
        $param = I('post.');

        $validateRule = array(
            'hotel' => 'notnull,notempty,id',
            'start' => 'notnull,notempty,isDate',
            'end' => 'notnull,notempty,isDate',
        );
        $this->ajaxValidateReturn($this->validateUtil, $param, $validateRule);

        $hotelId = $param['hotel'];
        $startDate = $param['start'];
        $endDate = $param['end'];
        $reportLogic = A('Common/Report', 'Logic');

        $financeData = $reportLogic->getHotelInOutComeData($hotelId, $startDate, $endDate);
        // 处理数据
        foreach ($financeData['info'] as &$payInfoItem) {
            unset($payInfoItem['id']);
            unset($payInfoItem['orderinfo_id']);
            unset($payInfoItem['orderrecord_id']);
            unset($payInfoItem['hotelentity_id']);
            unset($payInfoItem['hotelpay_id']);
            unset($payInfoItem['creator']);
            $payInfoItem['type'] = $payInfoItem['typename'];
            unset($payInfoItem['typename']);
            $payInfoItem['date'] = substr($payInfoItem['createtime'], 0, 10);
            unset($payInfoItem['createtime']);
            $payInfoItem['by'] = $payInfoItem['payname'];
            unset($payInfoItem['payname']);
            $payInfoItem['total'] = $payInfoItem['pay'];
            unset($payInfoItem['pay']);
            $payInfoItem['name'] = $payInfoItem['creatorname'];
            unset($payInfoItem['creatorname']);
            $payInfoItem['from'] = $payInfoItem['channelname'];
            unset($payInfoItem['channelname']);
        }
        unset($payInfoItem);

        // 获取财政收入统计
        $summary = $reportLogic->getSummary($hotelId, $startDate, $endDate);
        $returnData = array(
            'surplusSeries' => $financeData['total'],
            'incomeSeries' => $financeData['in'],
            'outcomeSeries' => $financeData['out'],
            'orders' => $financeData['info'],
            'total' => $financeData['itemtotal'],
            'pages' => $financeData['pagetotal'],
            'income' => $summary['receipt'] + $summary['deposit'],
            'incomeReceipt' => $summary['receipt'],
            'incomeDeposit' => $summary['deposit'],
            'outcome' => $summary['refund'] + $summary['refundDeposit'],
            'outcomeRefund' => $summary['refund'],
            'outcomeDeposit' => $summary['refundDeposit'],
        );
        //surplus总结余
        $returnData['surplus'] = number_format($returnData['income'] - $returnData['outcome'], 2, '.', '');

        returnJson(200, 200, $returnData);
    }

    /**
     * 财务收支ajax接口获取分页table
     * @modify AmosZhong 2016-01-18
     */
    public function getFinanceOrder() {
        $param = I('post.');
        $validateRule = array(
            'hotel' => 'notnull,notempty,id',
            'start' => 'notnull,notempty,isDate',
            'end' => 'notnull,notempty,isDate',
            'current' => 'notnull,notempty,natureNumber',
        );
        $this->ajaxValidateReturn($this->validateUtil, $param, $validateRule);

        $hotelId = $param['hotel'];
        $startDate = $param['start'];
        $endDate = $param['end'];
        $pageIndex = $param['current'];
        $orderLogic = A('Common/Order', 'Logic');
        try {
            $financeOrder = $orderLogic->getHotelOrderPayInfoByDate($hotelId, $startDate, $endDate, $pageIndex, C('PAGE_SIZE'));
        } catch (\Exception $e) {
            returnJson($e->getMessage());
            return;
        }

        // 处理数据
        foreach ($financeOrder['data'] as &$payInfoItem) {
            unset($payInfoItem['id']);
            unset($payInfoItem['orderinfo_id']);
            unset($payInfoItem['orderrecord_id']);
            unset($payInfoItem['hotelentity_id']);
            unset($payInfoItem['hotelpay_id']);
            unset($payInfoItem['creator']);
            $payInfoItem['type'] = $payInfoItem['typename'];
            unset($payInfoItem['typename']);
            $payInfoItem['date'] = substr($payInfoItem['createtime'], 0, 10);
            unset($payInfoItem['createtime']);
            $payInfoItem['by'] = $payInfoItem['payname'];
            unset($payInfoItem['payname']);
            $payInfoItem['total'] = $payInfoItem['pay'];
            unset($payInfoItem['pay']);
            $payInfoItem['name'] = $payInfoItem['creatorname'];
            unset($payInfoItem['creatorname']);
            $payInfoItem['from'] = $payInfoItem['channelname'];
            unset($payInfoItem['channelname']);
        }
        unset($payInfoItem);

        returnJson(200, 200,
                array(
            'orders' => $financeOrder['data'],
            'total' => $financeOrder['total'],
            'pages' => $financeOrder['pageTotal'],
            'currentPage' => $financeOrder['current'],
        ));
    }

    /**
     * @description 
     * @modify songanwei 2016-01-21
     */
    public function exportPay() {
        $params = I('get.');
        $validateRule = array(
            'hotel' => 'notnull,notempty,id',
            'start' => 'notnull,notempty,isDate',
            'end' => 'notnull,notempty,isDate',
        );
        //检查参数
        $this->ajaxValidateReturn($this->validateUtil, $params, $validateRule);
        $hotelId = $params['hotel'];
        $startDate = $params['start'];
        $endDate = $params['end'];

        Vendor('phpExcel.PHPExcel');
        $phpExcel = new \PHPExcel();
        //Excel2005格式
        $objWriter = new \PHPExcel_Writer_Excel5($phpExcel);
        //查询客栈数据
        $hotelEntityModel = D('HotelEntity');
        $hotelEntity = $hotelEntityModel->getInfo($hotelId);

        $outputFileName = $hotelEntity['name'] . date("Y.m.d");
        switch (LANG_SET) {
            case 'en_us':
                $outputFileName .= "Order receipt and payment details";
                //设置导出Excel标题
                $phpExcel->setActiveSheetIndex(0);
                $phpExcel->getActiveSheet()->setCellValue('A1', 'Date'); //可以指定位置
                $phpExcel->getActiveSheet()->setCellValue('B1', 'Operator');
                $phpExcel->getActiveSheet()->setCellValue('C1', 'Remarks information');
                $phpExcel->getActiveSheet()->setCellValue('D1', 'Order source');
                $phpExcel->getActiveSheet()->setCellValue('E1', 'Payment method');
                $phpExcel->getActiveSheet()->setCellValue('F1', 'Types of revenue and expenditure');
                $phpExcel->getActiveSheet()->setCellValue('G1', 'Amount');
                break;
            case 'zh_tw':
                $outputFileName .= "訂單收支明細";
                //设置导出Excel标题
                $phpExcel->setActiveSheetIndex(0);
                $phpExcel->getActiveSheet()->setCellValue('A1', '日期'); //可以指定位置
                $phpExcel->getActiveSheet()->setCellValue('B1', '操作人');
                $phpExcel->getActiveSheet()->setCellValue('C1', '備註資訊');
                $phpExcel->getActiveSheet()->setCellValue('D1', '訂單來源');
                $phpExcel->getActiveSheet()->setCellValue('E1', '支付方式');
                $phpExcel->getActiveSheet()->setCellValue('F1', '收支類型');
                $phpExcel->getActiveSheet()->setCellValue('G1', '金額');
                break;
            default:
                $outputFileName .= "订单收支明细";
                //设置导出Excel标题
                $phpExcel->setActiveSheetIndex(0);
                $phpExcel->getActiveSheet()->setCellValue('A1', '日期'); //可以指定位置
                $phpExcel->getActiveSheet()->setCellValue('B1', '操作人');
                $phpExcel->getActiveSheet()->setCellValue('C1', '备注信息');
                $phpExcel->getActiveSheet()->setCellValue('D1', '订单来源');
                $phpExcel->getActiveSheet()->setCellValue('E1', '支付方式');
                $phpExcel->getActiveSheet()->setCellValue('F1', '收支类型');
                $phpExcel->getActiveSheet()->setCellValue('G1', '金额');
                break;
        }    

        //获取输出的数据
        $orderLogic = A('Common/Order', 'Logic');
        try {
            $data = $orderLogic->getHotelOrderPayInfoByDate($hotelId, $startDate, $endDate);
        } catch (\Exception $e) {
            returnJson($e->getMessage());
            return;
        }

        //获取表单数据
        for ($i = 0; $i < count($data); $i++) {
            $phpExcel->getActiveSheet()->setCellValue('A' . ($i + 2), substr($data[$i]['createtime'], 0, 10));
            $phpExcel->getActiveSheet()->setCellValue('B' . ($i + 2), $data[$i]['creatorname']);
            $phpExcel->getActiveSheet()->setCellValue('C' . ($i + 2), $data[$i]['remark']);
            $phpExcel->getActiveSheet()->setCellValue('D' . ($i + 2), $data[$i]['channelname']);
            $phpExcel->getActiveSheet()->setCellValue('E' . ($i + 2), $data[$i]['payname']);
            $phpExcel->getActiveSheet()->setCellValue('F' . ($i + 2), $data[$i]['typename']);
            $phpExcel->getActiveSheet()->setCellValue('G' . ($i + 2), $data[$i]['pay']);
        }
        //输出excel文档
        phpExcelOutput($objWriter, $outputFileName);
    }

    /**
     * @description 
     * @modify songanwei 2016-01-20
     */
    public function getRoomReport() {
        $params = I('post.');
        $validateRule = array(
            'hotel' => 'notnull,notempty,id',
            'start' => 'notnull,notempty,isDate',
            'end' => 'notnull,notempty,isDate',
        );
        //检查参数
        $this->ajaxValidateReturn($this->validateUtil, $params, $validateRule);
        $hotelId = $params['hotel'];
        $startDate = $params['start'];
        $endDate = $params['end'];
        //检查参数

        $reportLogic = A('Common/Report', 'Logic');
        $result = $reportLogic->getRoomDetail($hotelId, $startDate, $endDate);

        returnJson(200, 200, $result);
    }

    /**
     * @description 
     * @modify zhangzhen 2017-06-06
     */
    public function getHourRoomReport() {
        $params = I('post.');
        $validateRule = array(
            'hotel' => 'notnull,notempty,id',
            'start' => 'notnull,notempty,isDate',
            'end' => 'notnull,notempty,isDate',
        );
        //检查参数
        $this->ajaxValidateReturn($this->validateUtil, $params, $validateRule);
        $hotelId = $params['hotel'];
        $startDate = $params['start'];
        $endDate = $params['end'];
        //检查参数

        $reportLogic = A('Common/Report', 'Logic');
        $result = $reportLogic->getRoomDetail($hotelId, $startDate, $endDate, 1);

        returnJson(200, 200, $result);
    }
    /**
     * @description 
     * @modify songanwei 2017-08-14
     */
    public function getLongRoomReport() {
        $params = I('post.');
        $validateRule = array(
            'hotel' => 'notnull,notempty,id',
            'start' => 'notnull,notempty,isDate',
            'end' => 'notnull,notempty,isDate',
        );
        //检查参数
        $this->ajaxValidateReturn($this->validateUtil, $params, $validateRule);
        $hotelId = $params['hotel'];
        $startDate = $params['start'];
        $endDate = $params['end'];
        //检查参数

        $reportLogic = A('Common/Report', 'Logic');
        $result = $reportLogic->getRoomDetail($hotelId, $startDate, $endDate, 2);

        returnJson(200, 200, $result);
    }


    /**
     * @description 导出报表
     * @modify songanwei 2016-01-20
     */
    public function exportRoom() {
        $params = I('get.');
        $validateRule = array(
            'hotel' => 'notnull,notempty,id',
            'start' => 'notnull,notempty,isDate',
            'end' => 'notnull,notempty,isDate',
        );
        //检查参数
        $this->ajaxValidateReturn($this->validateUtil, $params, $validateRule);
        $hotelId = $params['hotel'];
        $startDate = $params['start'];
        $endDate = $params['end'];
        $type = isset($params['type']) ? $params['type'] : 1;
        Vendor('phpExcel.PHPExcel');
        $phpExcel = new \PHPExcel();
        //Excel5格式
        $objWriter = new \PHPExcel_Writer_Excel5($phpExcel);
        //查询客栈数据
        $hotelEntityModel = D('HotelEntity');
        $hotelEntity = $hotelEntityModel->getInfo($hotelId);

        $outputFileName = $hotelEntity['name'] . date("Y.m.d");
        switch (LANG_SET) {
            case 'en_us':
                $outputFileName .= "Operational report";
                //输出文件名
                //设置导出Excel标题
                $phpExcel->setActiveSheetIndex(0);
                $phpExcel->getActiveSheet()->setCellValue('A1', 'Room type'); //可以指定位置
                $phpExcel->getActiveSheet()->setCellValue('B1', 'Room number');
                $phpExcel->getActiveSheet()->setCellValue('C1', 'Income');
                $phpExcel->getActiveSheet()->setCellValue('D1', 'Actual stay');
                $phpExcel->getActiveSheet()->setCellValue('E1', 'Occupancy rate');
                $phpExcel->getActiveSheet()->setCellValue('F1', 'Average price');
                $phpExcel->getActiveSheet()->setCellValue('G1', 'Not sold out');
                $phpExcel->getActiveSheet()->setCellValue('H1', 'No check in');
                $phpExcel->getActiveSheet()->setCellValue('I1', 'Room Type Statistics');
                break;
            case 'zh_tw':
                $outputFileName .= "運營報告";
                //输出文件名
                //设置导出Excel标题
                $phpExcel->setActiveSheetIndex(0);
                $phpExcel->getActiveSheet()->setCellValue('A1', '房間類型'); //可以指定位置
                $phpExcel->getActiveSheet()->setCellValue('B1', '房間號');
                $phpExcel->getActiveSheet()->setCellValue('C1', '收入');
                $phpExcel->getActiveSheet()->setCellValue('D1', '實住');
                $phpExcel->getActiveSheet()->setCellValue('E1', '入住率');
                $phpExcel->getActiveSheet()->setCellValue('F1', '平均價格');
                $phpExcel->getActiveSheet()->setCellValue('G1', '未售出');
                $phpExcel->getActiveSheet()->setCellValue('H1', '未入住');
                $phpExcel->getActiveSheet()->setCellValue('I1', '房型統計');
                break;
            default:
                 $outputFileName .= "运营报告";
                //输出文件名
                //设置导出Excel标题
                $phpExcel->setActiveSheetIndex(0);
                $phpExcel->getActiveSheet()->setCellValue('A1', '房间类型'); //可以指定位置
                $phpExcel->getActiveSheet()->setCellValue('B1', '房间号');
                $phpExcel->getActiveSheet()->setCellValue('C1', '收入');
                $phpExcel->getActiveSheet()->setCellValue('D1', '实住');
                $phpExcel->getActiveSheet()->setCellValue('E1', '入住率');
                $phpExcel->getActiveSheet()->setCellValue('F1', '平均价格');
                $phpExcel->getActiveSheet()->setCellValue('G1', '未售出');
                $phpExcel->getActiveSheet()->setCellValue('H1', '未入住');
                $phpExcel->getActiveSheet()->setCellValue('I1', '房型统计');
                break;
        }

        $reportLogic = A('Common/Report', 'Logic');

        $reportLogic = A('Common/Report', 'Logic');
        if ($type === 1){
            $data = $reportLogic->getRoomDetail($hotelId, $startDate, $endDate);
        } elseif($type === 2){
            $data = $reportLogic->getRoomDetail($hotelId, $startDate, $endDate, 1);
        } else {
            $data = $reportLogic->getRoomDetail($hotelId, $startDate, $endDate, 2);
        }

        $index = 2;
        for ($i = 0; $i < count($data['roomInfo']); $i++) {
            for ($j = 0; $j < count($data['roomInfo'][$i]['rooms']); $j++) {
                $phpExcel->getActiveSheet()->setCellValueExplicit('A' . $index, $data['roomInfo'][$i]['name'], \PHPExcel_Cell_DataType::TYPE_STRING);
                $phpExcel->getActiveSheet()->setCellValueExplicit('B' . $index, $data['roomInfo'][$i]['rooms'][$j]['name'], \PHPExcel_Cell_DataType::TYPE_STRING);
                $phpExcel->getActiveSheet()->setCellValue('C' . $index, $data['roomInfo'][$i]['rooms'][$j]['total']);
                $phpExcel->getActiveSheet()->setCellValue('D' . $index, $data['roomInfo'][$i]['rooms'][$j]['actualOccupancy']);
                $phpExcel->getActiveSheet()->setCellValue('E' . $index, $data['roomInfo'][$i]['rooms'][$j]['occupancyRate'] . "%");
                $phpExcel->getActiveSheet()->setCellValue('F' . $index, $data['roomInfo'][$i]['rooms'][$j]['price']);
                $phpExcel->getActiveSheet()->setCellValue('G' . $index, $data['roomInfo'][$i]['rooms'][$j]['notSold']);
                $phpExcel->getActiveSheet()->setCellValue('H' . $index, $data['roomInfo'][$i]['rooms'][$j]['notCheckIn']);
                // if ((($index - 2) + $j) % $i == 0) {
                switch (LANG_SET) {
                    case 'en_us':
                        $tempStr = "Total income：" . $data['roomInfo'][$i]['total'] . ",Occupancy rate：" . $data['roomInfo'][$i]['occupancyRate'] . "%,Average price：" . $data['roomInfo'][$i]['price'];
                        break;
                    case 'zh_tw':
                        $tempStr = "總收入：" . $data['roomInfo'][$i]['total'] . ",入住率：" . $data['roomInfo'][$i]['occupancyRate'] . "%,平均房價：" . $data['roomInfo'][$i]['price'];
                        break;
                    default:
                        $tempStr = "总收入：" . $data['roomInfo'][$i]['total'] . ",入住率：" . $data['roomInfo'][$i]['occupancyRate'] . "%,平均房价：" . $data['roomInfo'][$i]['price'];
                        break;
                }
                
                $phpExcel->getActiveSheet()->setCellValue('I' . $index, $tempStr);

                $index++;
            }
        }
        //输出excel文档
        phpExcelOutput($objWriter, $outputFileName);
    }
    /**
     * 财务收支ajax接口
     * @modify AmosZhong 2016-01-18
     */
    public function getVipFinance() {
        $param = I('post.');

        $validateRule = array(
            'hotel' => 'notnull,notempty,id',
            'start' => 'notnull,notempty,isDate',
            'end' => 'notnull,notempty,isDate',
        );
        $this->ajaxValidateReturn($this->validateUtil, $param, $validateRule);

        $hotelId = $param['hotel'];
        $startDate = $param['start'];
        $endDate = $param['end'];
        $reportLogic = A('Common/Report', 'Logic');

        $financeData = $reportLogic->getVipFinanceData($hotelId, $startDate, $endDate);
        returnJson(200, 200, $financeData);
    }

    /**
     * 财务收支ajax接口
     * @modify AmosZhong 2016-01-18
     */
    public function getCharity() {
        $param = I('post.');

        $validateRule = array(
            'hotel' => 'notnull,notempty,id',
            'start' => 'notnull,notempty,isDate',
            'end' => 'notnull,notempty,isDate',
        );
        $this->ajaxValidateReturn($this->validateUtil, $param, $validateRule);

        $hotelId = $param['hotel'];
        $startDate = $param['start'];
        $endDate = $param['end'];
        $current = isset($param['current']) ? $param['current'] : 1;
        $reportLogic = A('Common/Report', 'Logic');

        $charityData = $reportLogic->getCharityData($hotelId, $startDate, $endDate, $current);
        returnJson(200, 200, $charityData);
    }

    /**
     * 记账概览ajax接口
     * @modify wenhui 2017-12-19
     */
    public function getAccountView() {
        $param = I('post.');

        $validateRule = array(
            'hotel' => 'notnull,notempty,id',
            'type' => 'notnull,notempty,id',
            'start' => 'notnull,notempty,isDate',
            'end' => 'notnull,notempty,isDate',
        );
        $this->ajaxValidateReturn($this->validateUtil, $param, $validateRule);

        $hotelId = $param['hotel'];
        $type = $param['type'];
        $startDate = $param['start'];
        $endDate = $param['end'];
        $reportLogic = A('Common/Report', 'Logic');

        $accountData = $reportLogic->getHotelAccountView($hotelId, $type, $startDate, $endDate);
        //记账总结余
        $notesurplus = number_format($accountData['income'] - $accountData['outcome'], 2, '.', '');

        $returnData = array(
            'account' => $accountData['info'],
            'total' => $accountData['itemtotal'],
            'pages' => $accountData['pagetotal'],
            'current' => $accountData['current'],
            'income' => $accountData['income'],
            'outcome' => $accountData['outcome'],
            'notesurplus' => $notesurplus,
        );

        returnJson(200, 200, $returnData);
    }

    /**
     * 记账概览ajax接口获取分页table
     * @modify wenhui 2017-12-19
     */
    public function getAccountViewData() {
        $param = I('post.');
        $validateRule = array(
            'hotel' => 'notnull,notempty,id',
            'type' => 'notnull,notempty,id',
            'start' => 'notnull,notempty,isDate',
            'end' => 'notnull,notempty,isDate',
            'current' => 'notnull,notempty,natureNumber',
        );
        $this->ajaxValidateReturn($this->validateUtil, $param, $validateRule);

        $hotelId = $param['hotel'];
        $type = $param['type'];
        $startDate = $param['start'];
        $endDate = $param['end'];
        $pageIndex = $param['current'];

        $reportLogic = A('Common/Report', 'Logic');
        $accountData = $reportLogic->getHotelAccountView($hotelId, $type, $startDate, $endDate, $pageIndex);

        returnJson(200, 200,
                array(
            'account' => $accountData['info'],
            'total' => $accountData['itemtotal'],
            'pages' => $accountData['pagetotal'],
            'currentPage' => $accountData['current'],
        ));
    }

    /**
     * @description 记账导出表格
     * @modify wenhui 2017-12-19
     */
    public function exportNoteCost() {
        $params = I('get.');
        $validateRule = array(
            'hotel' => 'notnull,notempty,id',
            'type' => 'notnull,notempty,id',
            'start' => 'notnull,notempty,isDate',
            'end' => 'notnull,notempty,isDate',
        );
        //检查参数
        $this->ajaxValidateReturn($this->validateUtil, $params, $validateRule);
        $hotelId = $params['hotel'];
        $type = $params['type'];
        $startDate = $params['start'];
        $endDate = $params['end'];

        Vendor('phpExcel.PHPExcel');
        $phpExcel = new \PHPExcel();
        //Excel2005格式
        $objWriter = new \PHPExcel_Writer_Excel5($phpExcel);
        //查询客栈数据
        $hotelEntityModel = D('HotelEntity');
        $hotelEntity = $hotelEntityModel->getInfo($hotelId);

        $outputFileName = $hotelEntity['name'] . date("Y.m.d");
        switch (LANG_SET) {
            case 'en_us':
                $outputFileName .= "Account details";
                //设置导出Excel标题
                $phpExcel->setActiveSheetIndex(0);
                $phpExcel->getActiveSheet()->setCellValue('A1', 'Date'); //可以指定位置
                $phpExcel->getActiveSheet()->setCellValue('B1', 'Item,');
                $phpExcel->getActiveSheet()->setCellValue('C1', 'Price');
                $phpExcel->getActiveSheet()->setCellValue('D1', 'Payment method');
                $phpExcel->getActiveSheet()->setCellValue('E1', 'Remarks');
                $phpExcel->getActiveSheet()->setCellValue('F1', 'Operator');
                break;
            case 'zh_tw':
                $outputFileName .= "记账收支明细";
                //设置导出Excel标题
                $phpExcel->setActiveSheetIndex(0);
                $phpExcel->getActiveSheet()->setCellValue('A1', '日期'); //可以指定位置
                $phpExcel->getActiveSheet()->setCellValue('B1', '項目');
                $phpExcel->getActiveSheet()->setCellValue('C1', '金額');
                $phpExcel->getActiveSheet()->setCellValue('D1', '支付方式');
                $phpExcel->getActiveSheet()->setCellValue('E1', '備註');
                $phpExcel->getActiveSheet()->setCellValue('F1', '操作人');
                break;
            default:
                $outputFileName .= "记账收支明细";
                //设置导出Excel标题
                $phpExcel->setActiveSheetIndex(0);
                $phpExcel->getActiveSheet()->setCellValue('A1', '日期'); //可以指定位置
                $phpExcel->getActiveSheet()->setCellValue('B1', '项目');
                $phpExcel->getActiveSheet()->setCellValue('C1', '金额');
                $phpExcel->getActiveSheet()->setCellValue('D1', '支付方式');
                $phpExcel->getActiveSheet()->setCellValue('E1', '备注');
                $phpExcel->getActiveSheet()->setCellValue('F1', '操作人');
                break;
        }

        //获取输出的数据
        $reportLogic = A('Common/Report', 'Logic');
        $data = $reportLogic->getHotelAccountView($hotelId, $type, $startDate, $endDate, null);

        //获取表单数据
        for ($i = 0; $i < count($data); $i++) {
            $phpExcel->getActiveSheet()->setCellValue('A' . ($i + 2), $data[$i]['noteDate']);
            $phpExcel->getActiveSheet()->setCellValue('B' . ($i + 2), $data[$i]['noteName']);
            $phpExcel->getActiveSheet()->setCellValue('C' . ($i + 2), $data[$i]['notePrice']);
            $phpExcel->getActiveSheet()->setCellValue('D' . ($i + 2), $data[$i]['notePay']);
            $phpExcel->getActiveSheet()->setCellValue('E' . ($i + 2), $data[$i]['noteRemark']);
            $phpExcel->getActiveSheet()->setCellValue('F' . ($i + 2), $data[$i]['noteOperator']);
        }
        //输出excel文档
        phpExcelOutput($objWriter, $outputFileName);
    }


    /**
     * @description 订单其他消费细明
     * @modify wenhui 2017-12-19
     */
    public function getOrderCost() {
        $params = I('post.');
        $validateRule = array(
            'hotel' => 'notnull,notempty,id',
            'start' => 'notnull,notempty,isDate',
            'end' => 'notnull,notempty,isDate',
        );
        //检查参数
        $this->ajaxValidateReturn($this->validateUtil, $params, $validateRule);
        $hotelId = $params['hotel'];
        $startDate = $params['start'];
        $endDate = $params['end'];
        $pageIndex = isset($params['current']) ? $params['current'] : 1;
        //检查参数

        $reportLogic = A('Common/Report', 'Logic');
        $data = $reportLogic->getOrderCostDetail($hotelId, $startDate, $endDate, true, $pageIndex);

        foreach ($data['info'] as $key => &$item) {
           unset($item['detail']);
           unset($item['sortTime']);
        }

        returnJson(200, 200, $data);
    }

    /**
     * @description 其他消费细明
     * @modify wenhui 2017-12-19
     */
    public function getOrderCostDetail() {
        $params = I('post.');
        $validateRule = array(
            'hotel' => 'notnull,notempty,id',
            'orderId' => 'notnull,notempty,id',
            'start' => 'notnull,notempty,isDate',
            'end' => 'notnull,notempty,isDate',
        );
        //检查参数
        $this->ajaxValidateReturn($this->validateUtil, $params, $validateRule);
        $hotelId = $params['hotel'];
        $orderId = $params['orderId'];
        $startDate = $params['start'];
        $endDate = $params['end'];
        //检查参数

        $reportLogic = A('Common/Report', 'Logic');
        $data = $reportLogic->getOrderCostDetail($hotelId, $startDate, $endDate, true, null, $orderId);

        returnJson(200, 200, $data[0]['detail']);
    }

    /**
     * @description 其他消费细明
     * @modify wenhui 2017-12-19
     */
    public function deleteOrderCost() {
        $params = I('post.');
        $validateRule = array(
            'hotel' => 'notnull,notempty,id',
            'orderId' => 'notnull,notempty,id',
        );
        //检查参数
        $this->ajaxValidateReturn($this->validateUtil, $params, $validateRule);
        $hotelId = $params['hotel'];
        $orderId = $params['orderId'];

        $orderPayRecordModel = D('OrderPayRecord');
        $result = $orderPayRecordModel->deleteInfo($hotelId, $orderId);
        if ($result === false) {
            returnJson(500, 510);
        }

        returnJson(200, 200);
    }
}
